package utilAjax;

import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import daoJDBC.interfaceDO.serviceDO.Do_IDUS;


public class ajaxServlet extends HttpServlet {

	Do_IDUS idus=new Do_IDUS();
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		//获取前台传入的参数name
		String name=request.getParameter("name");
		System.out.println("转码前的值》》》"+name);
		//name = new String(name.getBytes("iso-8859-1"),"utf-8");
		//name=URLEncoder.encode(name, "ISO-8859-1");//编码---先把前台发过来的数据再次编码
		//name=URLDecoder.decode(name, "UTF-8");//解码----然后
		System.out.println("--ajaxServlet接收的name值--"+name);
		/*
		String sql="select * from user where name=?";
		Object []obj=new Object[]{name};
		idus.dosql(sql, obj);
		ResultSet rs=idus.getRS();
		if (rs!=null) {
			response.getWriter().write("<font color='red'>此用户名已被注册</font>");
		}else {
			response.getWriter().write("<font color='green'>此用户名可注册</font>");
		}
		*/
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String name=request.getParameter("name");
		System.out.println("转码前的值》》》"+name);
		//name = new String(name.getBytes("iso-8859-1"),"utf-8");
		//name=URLEncoder.encode(name, "ISO-8859-1");//编码---先把前台发过来的数据再次编码
		//name=URLDecoder.decode(name, "UTF-8");//解码----然后
		System.out.println("--ajaxServlet接收的name值--"+name);
	}

}
